<template>
  <a-card class="metric-card" :class="`metric-${type}`">
    <div class="metric-content">
      <div class="metric-icon">
        <i :class="icon"></i>
      </div>
      <div class="metric-info">
        <div class="metric-value">{{ value }}</div>
        <div class="metric-label">{{ label }}</div>
        <div class="metric-trend" :class="trendClass">
          <i v-if="trend > 0" class="icon icon-arrow-up"></i>
          <i v-else class="icon icon-arrow-down"></i>
          {{ Math.abs(trend) }}% {{ trendText }}
        </div>
      </div>
    </div>
  </a-card>
</template>

<script lang="ts" setup>
  interface Props {
    type: 'primary' | 'success' | 'warning' | 'info';
    icon: string;
    label: string;
    value: string | number;
    trend: number;
    trendText: string;
    trendClass: string;
  }

  defineProps<Props>();
</script>

<style lang="less" scoped>
  .metric-card {
    height: 100px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    &:hover {
      transform: translateY(-4px);
      box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
      background: rgba(255, 255, 255, 0.95);
    }

    &.metric-primary {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;

      .metric-icon {
        background: rgba(255, 255, 255, 0.2);
        color: white;
      }

      .metric-info {
        .metric-value,
        .metric-label,
        .metric-trend {
          color: white !important;
        }
      }
    }

    &.metric-success {
      background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
      color: white;

      .metric-icon {
        background: rgba(255, 255, 255, 0.2);
        color: white;
      }

      .metric-info {
        .metric-value,
        .metric-label,
        .metric-trend {
          color: white !important;
        }
      }
    }

    &.metric-warning {
      background: linear-gradient(135deg, #fcb045 0%, #fd1d1d 100%);
      color: white;

      .metric-icon {
        background: rgba(255, 255, 255, 0.2);
        color: white;
      }

      .metric-info {
        .metric-value,
        .metric-label,
        .metric-trend {
          color: white !important;
        }
      }
    }

    &.metric-info {
      background: linear-gradient(
        135deg,
        #833ab4 0%,
        #fd1d1d 50%,
        #fcb045 100%
      );
      color: white;

      .metric-icon {
        background: rgba(255, 255, 255, 0.2);
        color: white;
      }

      .metric-info {
        .metric-value,
        .metric-label,
        .metric-trend {
          color: white !important;
        }
      }
    }

    .metric-content {
      display: flex;
      align-items: center;
      height: 100%;

      .metric-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        margin-right: 16px;
        transition: all 0.3s ease;
      }

      .metric-info {
        flex: 1;

        .metric-value {
          font-size: 24px;
          font-weight: 600;
          line-height: 1.2;
          margin-bottom: 2px;
          color: inherit;
        }

        .metric-label {
          font-size: 13px;
          opacity: 0.9;
          margin-bottom: 6px;
          font-weight: 500;
          color: inherit;
        }

        .metric-trend {
          font-size: 11px;
          display: flex;
          align-items: center;
          gap: 4px;
          opacity: 0.8;
          font-weight: 500;
          color: inherit;

          i {
            font-size: 10px;
          }

          &.trend-up {
            color: rgba(255, 255, 255, 0.9);
          }

          &.trend-down {
            color: rgba(255, 255, 255, 0.9);
          }
        }
      }
    }
  }

  // 响应式处理
  @media screen and (max-width: 1200px) {
    .metric-card {
      height: 90px;

      .metric-content {
        .metric-icon {
          width: 32px;
          height: 32px;
        }

        .metric-info {
          .metric-value {
            font-size: 20px;
          }
        }
      }
    }
  }

  @media (max-width: 768px) {
    .metric-card {
      height: 80px;
      border-radius: 12px;

      .metric-content {
        .metric-icon {
          width: 28px;
          height: 28px;
          font-size: 14px;
          margin-right: 12px;
        }

        .metric-info {
          .metric-value {
            font-size: 18px;
          }

          .metric-label {
            font-size: 11px;
          }

          .metric-trend {
            font-size: 10px;
          }
        }
      }
    }
  }
</style>
